import Vue from "vue";
import Main from "./main.vue";
const load = Vue.extend(Main);

let instance;
let instances = [];
let seed = 1;
const PageLoad = function() {
  const id = "hm_load" + seed++;
  /**
   * 生成未挂载的实例
   */
  instance = new load();
  instance.id = id;
  /**
   * 将未挂载的组件挂载
   */
  instance.$mount();
  document.body.appendChild(instance.$el);
  // instance.visible = true;
  instances.push(instance);
  return instance;
};

PageLoad.close = function() {
  instances.forEach(val => {
    val.close();
  });
};
export default PageLoad;
